import request from "@/utils/request";
import { parseStrEmpty } from "@/utils/ruoyi";
import { uaaUrl, fileurl } from "@/utils/request";

// 查询用户列表
export function listUser(query) {
  return request({
    url: uaaUrl() + "api-system/v1/sysUser/sysUserListPage",
    method: "get",
    params: query,
  });
}

// 查询用户详细
export function getUser(userId) {
  return request({
    url: uaaUrl() + "api-system/v1/sysUser/" + parseStrEmpty(userId),
    method: "get",
  });
}

// 新增用户
export function addUser(data) {
  return request({
    url: uaaUrl() + "api-system/v1/sysUser",
    method: "post",
    data: data,
  });
}
// 查询角色列表
export function getRole() {
  return request({
    url: uaaUrl() + "api-system/v1/sysRole/optionselect",
    method: "get",
  });
}
// 修改用户
export function updateUser(data) {
  return request({
    url: uaaUrl() + "api-system/v1/sysUser",
    method: "put",
    data: data,
  });
}

// 删除用户
export function delUser(userId) {
  return request({
    url: uaaUrl() + "api-system/v1/sysUser/" + userId,
    method: "delete",
  });
}

// 用户密码重置
export function resetUserPwd(baseId, password) {
  const data = {
    baseId,
    password,
  };
  return request({
    url: uaaUrl() + "api-system/v1/sysUser/resetPwd",
    method: "post",
    data: data,
  });
}

// 用户状态修改
export function changeUserStatus(baseId, status) {
  const data = {
    baseId,
    status,
  };
  return request({
    url: uaaUrl() + "api-system/v1/sysUser/changeStatus",
    method: "put",
    data: data,
  });
}

// 查询用户个人信息
export function getUserProfile() {
  return request({
    url: uaaUrl() + "api-uaa/v1/user/info",
    method: "get",
  });
}

// 修改用户个人信息
export function updateUserProfile(data) {
  return request({
    url: uaaUrl() + "api-system/v1/system/user/profile",
    method: "put",
    data: data,
  });
}

// 用户密码重置
export function updateUserPwd(oldPassword, password, baseId) {
  const data = {
    oldPassword,
    password,
    baseId,
  };
  return request({
    url: uaaUrl() + "api-system/v1/sysUser/updatePwd",
    method: "post",
    data: data,
  });
}

// 用户头像上传
export function uploadAvatar(data) {
  return request({
    url: "/system/user/profile/avatar",
    method: "post",
    data: data,
  });
}

// 查询授权角色
export function getAuthRole(userId) {
  return request({
    url: "/system/user/authRole/" + userId,
    method: "get",
  });
}

// 保存授权角色
export function updateAuthRole(data) {
  return request({
    url: "/system/user/authRole",
    method: "put",
    params: data,
  });
}

// 查询部门下拉树结构
export function deptTreeSelect() {
  return request({
    url: uaaUrl() + "api-system/v1/sysDept/treeselectDept",
    method: "get",
  });
}
// 查询上级岗位
export function treeselectPost(deptId) {
  return request({
    url: uaaUrl() + "api-system/v1/sysPost/sysPostById?deptId=" + deptId,
    method: "get",
  });
}
//用户中心-用户信息详情
export function getSysUserInfoDetail(baseId) {
  return request({
    url: uaaUrl() + `api-system/v1/sysUserInfo/getSysUserInfoDetail/${baseId}`,
    method: "get",
  });
}
//用户中心-修改用户信息
export function saveOrUpdateSysUserInfo(data) {
  return request({
    url: uaaUrl() + `api-system/v1/sysUserInfo/saveOrUpdateSysUserInfo`,
    method: "post",
    data: data,
  });
}
//用户中心-更换证件
export function changeCard(data) {
  return request({
    url: uaaUrl() + `api-system/v1/sysUserInfo/changeCard`,
    method: "post",
    data: data,
  });
}
// 用户中心—单位变更记录
export function getSysUserChangeList(data) {
  return request({
    url: uaaUrl() + `api-system/v1/sysUserInfo/getSysUserChangeList`,
    method: "post",
    data: data,
  });
}
// // 用户中心-单位数据
// export function treeSelectDeptByKeyword(params) {
//   return request({
//     url: uaaUrl() + "api-system/v1/sysDept/treeSelectDeptByKeyword",
//     method: "get",
//     params: params,
//   });
// }
// 用户中心-单位数据
export function treeSelectDeptByDeptIds(data) {
  return request({
    url: uaaUrl() + "api-system/v1/sysDept/treeSelectDeptByDeptIds",
    method: "post",
    data,
  });
}
// 用户中心-变更单位
export function changeUnit(data) {
  return request({
    url: uaaUrl() + `api-system/v1/sysUserInfo/changeDept`,
    method: "post",
    data: data,
  });
}
// 用户中心-单位信息管理（政府部门）
export function findDeptInfoListPage(params) {
  return request({
    url: uaaUrl() + "api-system/v1/deptInfoChange/findDeptInfoListPage",
    method: "get",
    params: params,
  });
}
// 用户中心-单位信息管理-变更单位名称（政府部门）
export function updateDeptName(id, name) {
  return request({
    url:
      uaaUrl() +
      `api-system/v1/deptInfoChange/updateDeptName?baseId=${id}&deptName=${name}`,
    method: "post",
  });
}
// 用户中心-单位信息查询（政府部门）
export function findDeptInfo(params) {
  return request({
    url: uaaUrl() + "api-system/v1/deptInfoChange/findDeptInfoQueryListPage",
    method: "get",
    params: params,
  });
}
// 用户中心-查看申报人（政府部门）
export function getDeclareUserList(data) {
  return request({
    url: uaaUrl() + `api-system/v1/deptInfo/getDeclareUserList`,
    method: "post",
    data: data,
  });
}
// 用户中心-单位信息详情（政府部门）
export function getDeptInfoChangeDetail(params) {
  return request({
    url: uaaUrl() + `api-system/v1/deptInfoChange/getDeptInfoChangeDetail`,
    method: "get",
    params,
  });
}
// 用户中心-审核详情（政府部门）
export function getDeptInfoChangeAuditDetail(params) {
  return request({
    url: uaaUrl() + `api-system/v1/deptInfoChange/getDeptInfoChangeAuditDetail`,
    method: "get",
    params,
  });
}
// 用户中心-单位信息查询详情（政府部门）
export function getDeptInfoDetail(params) {
  return request({
    url: uaaUrl() + `api-system/v1/deptInfo/getDeptInfoDetail`,
    method: "get",
    params,
  });
}
// 用户中心-审核常用意见（政府部门）
export function reviewCommentListPage(params) {
  return request({
    url: uaaUrl() + `api-system/v1/reviewComment/reviewCommentListPage`,
    method: "get",
    params,
  });
}
// 用户中心-新增审核常用意见（政府部门）
export function addReviewComment(data) {
  return request({
    url: uaaUrl() + `api-system/v1/reviewComment/addReviewComment`,
    method: "post",
    data,
  });
}
// 用户中心-修改审核常用意见（政府部门）
export function updateReviewComment(data) {
  return request({
    url: uaaUrl() + `api-system/v1/reviewComment/updateReviewComment`,
    method: "post",
    data,
  });
}
// 用户中心-设置默认审核常用意见（政府部门）
export function updateDefaultComment(id) {
  return request({
    url: uaaUrl() + `api-system/v1/reviewComment/updateDefaultComment?id=` + id,
    method: "post",
  });
}
// 用户中心-删除审核常用意见（政府部门）
export function updateByIsDelete(id) {
  return request({
    url: uaaUrl() + `api-system/v1/reviewComment/updateByIsDelete/${id}`,
    method: "get",
  });
}
// 用户中心-获取默认审核常用意见（政府部门）
export function getDefaultComment() {
  return request({
    url: uaaUrl() + `api-system/v1/reviewComment/getDefaultComment`,
    method: "get",
  });
}
//新增黑名单
export function blacklist(data) {
  return request({
    url: uaaUrl() + `api-system/v1/blacklist`,
    method: "post",
    data,
  });
}
// 黑名单列表企业
export function findCompanyBlacklistListPage(params) {
  return request({
    url: uaaUrl() + `api-system/v1/blacklist/findCompanyBlacklistListPage`,
    method: "get",
    params,
  });
}
// 黑名单列表个人
export function findUserBlacklistListPage(params) {
  return request({
    url: uaaUrl() + `api-system/v1/blacklist/findUserBlacklistListPage`,
    method: "get",
    params,
  });
}
// 黑名单详情
export function blacklistDetail(id) {
  return request({
    url: uaaUrl() + `api-system/v1/blacklist/${id}`,
    method: "get",
  });
}
//提交处室
export function submitDept(type) {
  return request({
    url: uaaUrl() + `api-system/v1/blacklist/deptListByType?type=` + type,
    method: "get",
  });
}
//限制范围
export function restrictionScopeDeptListByType(type) {
  return request({
    url:
      uaaUrl() +
      `api-system/v1/blacklist/restrictionScopeDeptListByType?type=` +
      type,
    method: "get",
  });
}
//新增黑名单选择企业
export function companyPageList(params) {
  return request({
    url: uaaUrl() + `api-system/v1/blacklist/companyPageList`,
    method: "get",
    params,
  });
}
//新增黑名单选择个人
export function userPageList(params) {
  return request({
    url: uaaUrl() + `api-system/v1/blacklist/userPageList`,
    method: "get",
    params,
  });
}
//确认导入验证黑名单企业
export function batchSaveCompany(data) {
  return request({
    url: uaaUrl() + `api-system/v1/blacklist/batchSaveCompany`,
    method: "post",
    data,
  });
}
//确认导入验证黑名单个人
export function batchSaveUser(data) {
  return request({
    url: uaaUrl() + `api-system/v1/blacklist/batchSaveUser`,
    method: "post",
    data,
  });
}
//用户中心---反馈
// 意见公开不公开
export function updateIsPublic(baseId, isShow) {
  return request({
    url:
      uaaUrl() +
      `api-system/v1/feedback/updateShow?baseId=` +
      baseId +
      "&isShow=" +
      isShow,
    method: "post",
  });
}
//应用字典
export function oauthClientSelect() {
  return request({
    url: uaaUrl() + `api-uaa/v1/clients/oauthClientSelect`,
    method: "get",
  });
}
// 列表分页
export function findFeedbackListPage(params) {
  return request({
    url: uaaUrl() + `api-system/v1/feedback/findFeedbackListPage`,
    method: "get",
    params,
  });
}
// 详情
export function feedback(id) {
  return request({
    url: uaaUrl() + `api-system/v1/feedback/${id}`,
    method: "get",
  });
}
//处理反馈
export function process(data) {
  return request({
    url: uaaUrl() + `api-system/v1/feedback/process`,
    method: "post",
    data,
  });
}
// 导出非身份证人员
export function exportNonIdCardUserList(data) {
  return request({
    url: uaaUrl() + `api-system/v1/nonIdCardUser/exportNonIdCardUserList`,
    method: "post",
    responseType: "blob",
    data,
  });
}
//导出人员单位变更审核-政府
export function exportUserChangeList(data) {
  return request({
    url: uaaUrl() + `api-system/v1/sysUserInfo/exportUserChangeList`,
    method: "post",
    responseType: "blob",
    data,
  });
}
//导出人员单位变更审核-企业
export function exportUserCompanyChangeList(data) {
  return request({
    url: uaaUrl() + `api-system/v1/sysUserInfo/exportUserChangeList`,
    method: "post",
    responseType: "blob",
    data,
  });
}
// 授权人员管理
export function exportSysDeptAuthUserList(data) {
  return request({
    url: uaaUrl() + `api-system/v1/sysDeptAuthUser/exportSysDeptAuthUserList`,
    method: "post",
    responseType: "blob",
    data,
  });
}
//导出二级部门管理
export function exportSecondDept(data) {
  return request({
    url: uaaUrl() + `api-system/v1/deptInfo/exportSecondDept`,
    method: "post",
    responseType: "blob",
    data,
  });
}
//导出人员管理
export function exportUserForDept(data) {
  return request({
    url: uaaUrl() + `api-system/v1/deptInfo/exportUserForDept`,
    method: "post",
    responseType: "blob",
    data,
  });
}
//导出单位信息管理
export function exportDeptInfoList(data) {
  return request({
    url: uaaUrl() + `api-system/v1/deptInfoChange/exportDeptInfoList`,
    method: "post",
    responseType: "blob",
    data,
  });
}
//导出单位信息查询
export function exportDeptInfoQueryList(data) {
  return request({
    url: uaaUrl() + `api-system/v1/deptInfoChange/exportDeptInfoQueryList`,
    method: "post",
    responseType: "blob",
    data,
  });
}
//导出单位信息变更审核
export function exportChangeRecordList(data) {
  return request({
    url: uaaUrl() + `api-system/v1/deptInfoChange/exportChangeRecordList`,
    method: "post",
    responseType: "blob",
    data,
  });
}
//导出黑名单企业
export function exportCompanyBlacklistListPage(params) {
  return request({
    url: uaaUrl() + `api-system/v1/blacklist/exportCompanyBlacklistListPage`,
    method: "get",
    responseType: "blob",
    params,
  });
}
//导出黑名单个人
export function exportUserBlacklistListPage(params) {
  return request({
    url: uaaUrl() + `api-system/v1/blacklist/exportUserBlacklistListPage`,
    method: "get",
    responseType: "blob",
    params,
  });
}
//导出申报人
export function exportDeclareUser(data) {
  return request({
    url: uaaUrl() + `api-system/v1/deptInfo/exportDeclareUser`,
    method: "post",
    responseType: "blob",
    data,
  });
}
//账号管理-绑定手机号
export function bindMobile(telephone, msgCode) {
  return request({
    url:
      uaaUrl() +
      `api-system/v1/sysUser/bindMobile?telephone=` +
      telephone +
      "&msgCode=" +
      msgCode,
    method: "get",
  });
}
//账号管理-获取验证码
export function sendConfirmMobileCode(telephone, code, deviceId) {
  return request({
    url:
      uaaUrl() + "api-system/v1/sysUser/sendConfirmMobileCode?telephone=" + telephone
      + "&code=" + code + "&deviceId=" + deviceId,
    method: "get",
  });
}
//账号管理-绑定邮箱
export function bindEmail(userId) {
  return request({
    url: uaaUrl() + `api-system/v1/sysUser/bindEmail?userId=` + userId,
    method: "get",
  });
}
//账号管理-发送邮箱
export function sendConfirmEmailCode(email) {
  return request({
    url: uaaUrl() + `api-system/v1/sysUser/sendConfirmEmailCode?email=` + email,
    method: "get",
  });
}
//账号管理-验证手机号邮箱是否唯一
export function checkUniqueness(account) {
  return request({
    url: uaaUrl() + `api-system/v1/sysUser/checkUniqueness?account=` + account,
    method: "get",
  });
}
//收藏列表
export function findCollectionListPage(params) {
  return request({
    url: uaaUrl() + `api-system/v1/collection/findCollectionListPage`,
    method: "get",
    params,
  });
}
//取消收藏
export function collection(id) {
  return request({
    url: uaaUrl() + "api-system/v1/collection/delById/" + id,
    method: "get",
  });
}
//修改头像
export function updateUserHeader(header, userId) {
  return request({
    url:
      uaaUrl() +
      `api-system/v1/sysUser/updateUserHeader?header=` +
      header +
      "&userId=" +
      userId,
    method: "get",
  });
}

// 验证身份证号是否唯一
export function checkIdCardUnique(params) {
  return request({
    url: uaaUrl() + `api-system/v1/sysUser/checkIdNumberUniqueness`,
    method: "get",
    params,
  });
}

// 新增提名信息
export function addExpertNomination(data) {
  return request({
    url:
      // "http://123.232.102.29:33410/" +
      uaaUrl() + "api-award/v1/expertNomination/addExpertNomination",
    method: "post",
    data: data,
    // headers: {
    //   isToken: false,
    // },
  });
}
// 修改保存提名信息
export function editExpertNomination(data) {
  return request({
    url: uaaUrl() + "api-award/v1/expertNomination/updateUnitNominationInfo",
    method: "post",
    data: data
  });
}
// 根据用户id获取提名信息
export function getExpertNominationByUserId(userId) {
  return request({
    url:
      // "http://123.232.102.29:33410/" +
      uaaUrl() + "api-award/v1/expertNomination/getUserIdInfo/" + userId,
    method: "get",
    // headers: {
    //   isToken: false,
    // },
  });
}
// 根据id获取提名信息
export function getUserInfoByUserDetail(userId) {
  return request({
    url: uaaUrl() + "api-award/v1/expertNomination/getUserInfoByUserId?userId=" + userId,
    method: "get",
  });
}
// 联合提名新增
export function addJointExpertNomination(data) {
  return request({
    url: uaaUrl() + "api-award/v1/expertNomination/addJointExpertNomination",
    method: "post",
    data: data,
  });
}
// 联合提名详情
export function getJointUserInfoByUserDetail(userId) {
  return request({
    url: uaaUrl() + "api-award/v1/expertNomination/getJointUserInfoByUserId?userId=" + userId,
    method: "get",
  });
}
// 获取资质认定状态

export function getUserQualifications(userId) {
  return request({
    url: uaaUrl() + "api-award/v1/expertNomination/getUserQualifications?userId=" + userId,
    method: "get",
  });
}
